package o;

import android.text.SpannableStringBuilder;
import com.google.android.exoplayer2.text.Cue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

final class akw implements aji {
    private final int ˊ;
    private final List<ako> ˋ;
    private final long[] ˏ;
    private final long[] ॱ = new long[(this.ˊ * 2)];

    public akw(List<ako> list) {
        this.ˋ = list;
        this.ˊ = list.size();
        for (int i = 0; i < this.ˊ; i++) {
            ako o_ako = (ako) list.get(i);
            int i2 = i * 2;
            this.ॱ[i2] = o_ako.ͺ;
            this.ॱ[i2 + 1] = o_ako.ॱᐝ;
        }
        this.ˏ = Arrays.copyOf(this.ॱ, this.ॱ.length);
        Arrays.sort(this.ˏ);
    }

    public int ॱ(long j) {
        int ॱ = anr.ॱ(this.ˏ, j, false, false);
        return ॱ < this.ˏ.length ? ॱ : -1;
    }

    public int ॱ() {
        return this.ˏ.length;
    }

    public long ˊ(int i) {
        boolean z;
        boolean z2 = true;
        if (i >= 0) {
            z = true;
        } else {
            z = false;
        }
        amm.ˊ(z);
        if (i >= this.ˏ.length) {
            z2 = false;
        }
        amm.ˊ(z2);
        return this.ˏ[i];
    }

    public List<Cue> ˊ(long j) {
        CharSequence charSequence = null;
        int i = 0;
        ako o_ako = null;
        ArrayList arrayList = null;
        while (i < this.ˊ) {
            CharSequence charSequence2;
            ako o_ako2;
            ArrayList arrayList2;
            CharSequence charSequence3;
            if (this.ॱ[i * 2] > j || j >= this.ॱ[(i * 2) + 1]) {
                charSequence2 = charSequence;
                o_ako2 = o_ako;
                arrayList2 = arrayList;
                charSequence3 = charSequence2;
            } else {
                ArrayList arrayList3;
                if (arrayList == null) {
                    arrayList3 = new ArrayList();
                } else {
                    arrayList3 = arrayList;
                }
                ako o_ako3 = (ako) this.ˋ.get(i);
                if (!o_ako3.ˋ()) {
                    arrayList3.add(o_ako3);
                    charSequence3 = charSequence;
                    o_ako2 = o_ako;
                    arrayList2 = arrayList3;
                } else if (o_ako == null) {
                    arrayList2 = arrayList3;
                    ako o_ako4 = o_ako3;
                    charSequence3 = charSequence;
                    o_ako2 = o_ako4;
                } else if (charSequence == null) {
                    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
                    spannableStringBuilder.append(o_ako.ˊ).append("\n").append(o_ako3.ˊ);
                    Object obj = spannableStringBuilder;
                    o_ako2 = o_ako;
                    arrayList2 = arrayList3;
                } else {
                    charSequence.append("\n").append(o_ako3.ˊ);
                    charSequence3 = charSequence;
                    o_ako2 = o_ako;
                    arrayList2 = arrayList3;
                }
            }
            i++;
            charSequence2 = charSequence3;
            arrayList = arrayList2;
            o_ako = o_ako2;
            charSequence = charSequence2;
        }
        if (charSequence != null) {
            arrayList.add(new ako(charSequence));
        } else if (o_ako != null) {
            arrayList.add(o_ako);
        }
        return arrayList != null ? arrayList : Collections.emptyList();
    }
}
